#ifndef __STR_OPERATION_HEADER_FILE__
#define __STR_OPERATION_HEADER_FILE__

#include <string>
#include "OSHeaders.h"


#define STRINGTRANSLATORTESTING 0

using namespace std;

class CStrOperate
{
public:
	static string GetKeyValue(const string& strSrc, string strKeyItem, string strEndKey, int& nStartPos);
	static string GetKeyValue(const string& strSrc, string strKeyItem, string strEndKey);
	static string GetKeyValue(const string& strSrc, string strKeyItem, int nLength);
		
	static int ReplaceItemValue(string &strSrc, string strKeyItem, string strEndKey, const string strNewValue, int nStartPos=0);
	static int RemoveSubString(string &strSrc, string strKeyItem, string strEndKey);

	static void ConvertUnixToDos(std::string& strConvert);
	static Bool ModifyPath(std::string& path);
	static Bool Replace(std::string& str,std::string& where,std::string& val,Bool cycle=TRUE,Bool rfind=FALSE);
	//static Bool erase(std::string& str,std::string& val);
	static void TransPathFormat(string& strPath);
	static void TransPathToStdFormat(string& strPath);

	static Int32	StringToInt(const string &strSrc);
	static Int64	StringToInt64(const string &strSrc);
	static string	IntToString(Int32 vValue);
	static string	UIntToString(UInt32 vValue);
	static string	Int64ToString(Int64 vValue);
	static string	UInt64ToString(UInt64 vValue);
	
	static std::string GetExtName(const std::string& strFileName);
		
	//DecodeURL:
	//
	// This function does 2 things: Decodes % encoded characters in URLs, and strips out
	// any ".." or "." complete filenames from the URL. Writes the result into ioDest.
	//
	//If successful, returns the length of the destination string.
	//If failure, returns an OS errorcode: OS_BadURLFormat, OS_NotEnoughSpace
	
	static Int32   DecodeURL(const char* inSrc, Int32 inSrcLen, char* ioDest, Int32 inDestLen);
	
	//EncodeURL:
	//
	// This function takes a character string and % encodes any special URL characters.
	// In general, the output buffer will be longer than the input buffer, so caller should
	// be aware of that.
	//
	//If successful, returns the length of the destination string.
	//If failure, returns an QTSS errorcode: OS_NotEnoughSpace
	//
	// If function returns E2BIG, ioDest will be valid, but will contain
	// only the portion of the URL that fit.
	static Int32   EncodeURL(const char* inSrc, Int32 inSrcLen, char* ioDest, Int32 inDestLen);
	
	// DecodePath:
	//
	// This function converts "network" or "URL" path delimiters (the '/' char) to
	// the path delimiter of the local file system. It does this conversion in place,
	// so the old data will be overwritten
	static void     DecodePath(char* inSrc, UInt32 inSrcLen);

#if STRINGTRANSLATORTESTING
	static Bool       Test();
#endif  
	
};





#endif
